<template>
    <div>
        <el-table :data="$store.getters['sort/getSort']" border style="width: 100%" row-key="id" :load="load"
            :tree-props="{ children: 'children' }">
            <el-table-column prop="id" label="分类编号" width="180">
            </el-table-column>
            <el-table-column prop="catename" label="分类名称" width="180">
            </el-table-column>
            <el-table-column label="图片">
                <template slot-scope="item">
                    <div>
                        <img style="width:'60px';height: 60px;" :src="item.row.img" alt="">
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="状态">
                <template slot-scope="item">
                    <div>
                        <el-button type="success" plain size="mini">{{ item.row.status == 1 ? '启用' : '禁用' }}</el-button>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="item">
                    <div>
                        <el-button type="primary" size="mini" icon="el-icon-edit" circle
                            @click="edit(item.row.id)"></el-button>
                        <el-button type="danger" size="mini" icon="el-icon-delete" @click="del(item.row.id)"
                            circle></el-button>
                    </div>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
import { catedelete } from '../../request/api'
export default {
    data() {
        return {
        }
    },
    methods: {
        load() { },
        // 删除
        del(id) {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                catedelete({id})
                .then(res=>{
                    if(res.code == 200){
                        this.$message.success('删除成功')
                        this.$store.dispatch('sort/GetSortInfo')
                    }else{
                        this.$message.success('删除失败')
                    }
                })
                    
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        // 编辑
        edit(id) {
            this.$emit('sortadd',id)
        }
    },
    mounted() { },
    watch: {},
    computed: {},
    filters: {},
    components: {}
}
</script>
<style scoped></style>